/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.facades.view;

import com.sdd.entities.Customer;
import com.sdd.facades.business.CustomerBusinessFacadeBean;
import com.sdd.facades.factories.CustomerFactoryFacadeBean;
import com.sdd.plains.CustomerPlain;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author T
 */
@Stateless
public class CustomerViewFacadeBean implements CustomerViewFacade {

    @EJB
    CustomerBusinessFacadeBean customerBusinessFacadeBean;
    @EJB
    CustomerFactoryFacadeBean customerFactoryFacadeBean;

    @Override
    public CustomerPlain getCustomer(Long id) {
        Customer c = customerBusinessFacadeBean.getCustomer(id);
        return customerFactoryFacadeBean.createCustomerPlain(c);
        
    }

    @Override
    public List<CustomerPlain> getAllCustomers() {
        List<Customer> lc = customerBusinessFacadeBean.getAllCustomers();
        return customerFactoryFacadeBean.createListCustomerPlain(lc);
       
    }

    @Override
    public CustomerPlain addCustomer(CustomerPlain plain) {
        
        Customer c = customerBusinessFacadeBean.addCustomer(plain);
        return customerFactoryFacadeBean.createCustomerPlain(c);

    }

//    @Override
//    public CustomerPlain getCustomer(String parameter) {
//        throw new UnsupportedOperationException("Not supported yet.");
//    }
    @Override
    public CustomerPlain getCustomerByLogin(String login) {
        Customer c = customerBusinessFacadeBean.getCustomerbyLogin(login);
        return customerFactoryFacadeBean.createCustomerPlain(c);
    }

    @Override
    public CustomerPlain getCustomerByEmail(String Email) {
        Customer c = customerBusinessFacadeBean.getCustomerbyEmail(Email);
        return customerFactoryFacadeBean.createCustomerPlain(c);
    }
    
    @Override
    public boolean existEmail(String Email){
        return customerBusinessFacadeBean.existEmail(Email);
    }
    
    @Override
    public boolean existLogin(String Login){
        return customerBusinessFacadeBean.existLogin(Login);
    }
}
